package com.tastespot.config;


import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @Author: 369pro
 * @CreateTime: 2025-05-15
 * @Version: 1.0
 */
@Configuration
public class BloomFilterConfig {
    @Resource
    private RedissonClient redissonClient;

    @Bean
    public RBloomFilter<String> bloomFilter(){
        RBloomFilter<String> bloomFilter = redissonClient.getBloomFilter("bloomFilter");
        // 初始化布隆过滤器：预计插入数量为100000，误判率为0.01
        bloomFilter.tryInit(100000L, 0.01);
        return bloomFilter;
    }
}
